package com.example.service.impl;

import com.example.dao.RoleDao;
import com.example.entity.Role;
import com.example.service.RoleService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class RoleServiceImpl implements RoleService {
    private final RoleDao mapper;

    public RoleServiceImpl(RoleDao mapper) {
        this.mapper = mapper;
    }

    @Override
    public Role find(int id) {
        return mapper.find(id);
    }

    @Override
    @Transactional
    public void add(Role role) {
        mapper.add(role);
        // 测试事务回滚
        // throw new RuntimeException();
    }
}
